package com.cpi.cornpp.currency.service;

import java.util.List;

import com.cpi.cornpp.common.exception.CornPPException;
import com.cpi.cornpp.currency.converter.CurrencyConverter;
import com.cpi.cornpp.currency.dao.CurrencyDAO;
import com.cpi.cornpp.currency.exception.CurrencyException;

public class CurrencyService {
	public List getCurrencies()throws CurrencyException{
		List currencyViews = null;
		CurrencyDAO currencyDAO = null;
		List currencyDTOs = null;
		CurrencyConverter currencyConverter = null;
		try{
			currencyDAO = new CurrencyDAO();
			currencyConverter = new CurrencyConverter();
			currencyDTOs = currencyDAO.getCurrencies();
			currencyViews = currencyConverter.convertDTOsTOViews(currencyDTOs);
		}catch(CurrencyException currencyException){
			throw currencyException;
		}catch(Exception exception){
			CurrencyException currencyException = null;
			exception.printStackTrace(System.out);
			currencyException = new CurrencyException(exception, CornPPException.LAYER_SERVICE, CornPPException.ACTION_LISTS);
			throw currencyException;
		}
		return currencyViews;
	}
}